package dissertation.examples.ejb31.message;

import javax.ejb.MessageDriven;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

@MessageDriven(name = "LogEJB")
public class LogBean implements MessageListener {
    public LogBean() {
    }

    @Override
    public void onMessage(Message message) {
        if (message instanceof TextMessage){
            TextMessage tm = (TextMessage) message;
            try {
                String text = tm.getText();
                System.out.println("Received new message : " + text);
            } catch (JMSException e) {
                e.printStackTrace();
            }
        }
    }
}
